# Contributor: Russ Webber <russ@rw.id.au>
# Maintainer: Russ Webber <russ@rw.id.au>
pkgname=assimp
pkgver=5.0.0
pkgrel=1
pkgdesc="Open Asset Import Library imports and exports 3D model formats."
url="http://www.assimp.org/"
arch="all !s390x !mips !mips64" # fails to build on big-endian
license="BSD-3-Clause"
makedepends="cmake zlib-dev minizip-dev"
subpackages="$pkgname-dev"
source="assimp-$pkgver.tar.gz::https://github.com/assimp/assimp/archive/v$pkgver.tar.gz
        01-rm-revision-test.patch
        02-fix-ssize-32bit.patch"

build() {
  if [ "$CBUILD" != "$CHOST" ]; then
    CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
  fi

  cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DBUILD_SHARED_LIBS=True \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
    -DCMAKE_C_FLAGS="$CFLAGS" \
    -DASSIMP_BUILD_TESTS=True \
    ${CMAKE_CROSSOPTS} .
  make
}

check() {
  cd "$builddir"/bin
  ./unit
}

package() {
  make DESTDIR="$pkgdir" install
  rm -vf "$pkgdir"/usr/lib/libIrrXML.a
}

sha512sums="0f73b6e961cd8455d6b6c8c10ed8b99485d846c96377b5d4fcc3b83f737647207c1306aa3dd51dad9654fbfa61bfe1119b34646f90288ae7ecab45efa6fa418a  assimp-5.0.0.tar.gz
535a80c5899a2994735e7b17b4e3fdb3ff2b53e64c09ec8fcab1dbcea2ad696fed50aeb1667a3c4e00a8a3ddf411d33ec1d36fcb256e26f02cf951f0e2c83a73  01-rm-revision-test.patch
19a52d40887de945b74efe0f7e105a02eab306e6295d2d9b32f76bed9596c93ab954118df6e7afdafd2488e0e1feb666c734a8eb56e0edc34510efe3f8f99374  02-fix-ssize-32bit.patch"
